//takes in text array and creates button array
//  -position
// param0 = x value of top left corner
// param1 = y value of top left corner
//  -contents
// param2 = text[] button names
// param3 = intentType[] types of intents
// param4 = intent[] either room destination or action or menu
// param5 = title of menu
//  -dimensions
// param6 = menu width
// param7 = menu height
//  -visible
// param8 = visibility
//-if a level selection menu (true or false)
//  param9= levelSelect 

var X=argument0; 
var Y=argument1;
var text=argument2;
var intentType= argument3;
var intent=argument4;
var titleInput=argument5;
var menuWidth=argument6;
var menuHeight=argument7;
var visibility=argument8;
var lvlSelection=argument9;


var menu=instance_create(X,Y,oMenu);//menu=new menu(x,y);


with(menu){
    //create array of buttons
    //loop through array of buttons setting text and intent
    width=menuWidth;
    height=menuHeight;
    var titleHeight;
    if(titleInput=="")
        titleHeight=0;
    else
        titleHeight=70;
    var buttonVertSpacing=(height-titleHeight)/array_length_1d(text); 
    var whiteSpace=20;
    var buttonHeight= buttonVertSpacing-whiteSpace;
   
    
    for(var i=0; i<array_length_1d(text); i++) {
        if(intentType[i]==INTENT_TYPE_NONE)
            continue;
        buttons[i]=buttonConstructor(x,y+titleHeight+buttonVertSpacing*i,id,text[i],intentType[i],intent[i],i,menuWidth,
            buttonHeight,visibility,lvlSelection);
    }

    usingMouse=true;
    title=titleInput;
   
    mouse_prevx=mouse_x;
    mouse_prevy=mouse_y;
    visible=visibility;
    
    buttonIndex=-1;
    
    init=true;
}
return menu;
